package com.kmxd.ams.client.oss.vo;

import cn.hutool.core.io.unit.DataSizeUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 电子文件表
 *
 * @author ZuoLG
 * @since 2022-07-25
 */
@Data
@ColumnWidth(15)
@HeadRowHeight(15)
@ContentRowHeight(15)
@HeadStyle
@HeadFontStyle(fontHeightInPoints = 12)
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER)
@ContentFontStyle(fontHeightInPoints = 10)
@ExcelIgnoreUnannotated
@Schema(description = "电子文件表对象")
public class EfileRecordListVO implements Serializable {

  private static final long serialVersionUID = 1L;

  @Schema(description = "主键ID")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "主键ID")
  private Long id;

  @Schema(description = "全宗id")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "全宗id")
  private Long fondsId;

  @Schema(description = "门类id")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "门类id")
  private Long archTypeId;

  @Schema(description = "档案id")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "档案id")
  private Long archId;

  @Schema(description = "档案档号")
  @ExcelProperty(value = "档案档号")
  private String archCode;

  @Schema(description = "文件名")
  @ExcelProperty(value = "文件名")
  private String title;

  @Schema(description = "真实存储的名字")
  @ExcelProperty(value = "真实存储的名字")
  private String saveFileName;

  @Schema(description = "附件扩展名")
  @ExcelProperty(value = "附件扩展名")
  private String ext;

  /** 使用路径 */
  @Schema(description = "使用路径")
  @ExcelProperty(value = "使用路径")
  private String defPath;

  @Schema(description = "附件大小")
  @ExcelProperty(value = "附件大小")
  private String fileSize;

  @Schema(description = "附件大小格式化")
  @ExcelProperty(value = "附件大小格式化")
  private String fileSizeStr;

  @Schema(description = "附件保存路径")
  @ExcelProperty(value = "附件保存路径")
  private String path;

  @Schema(description = "挂接时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @ColumnWidth(20)
  @ExcelProperty(value = "挂接时间")
  private Date hangingTime;
  @Schema(description = "OCR识别内容")
  @ExcelProperty(value = "OCR识别内容")
  private String ocrContent;
  @Schema(description = "数据导入父标识")
  @ExcelProperty(value = "数据导入父标识")
  private String pid;
  @Schema(description = "装换状态：1待处理，2转换中，3成功，4失败，99不支持转换，0不需要转换")
  @ExcelProperty(value = "装换状态：1待处理，2转换中，3成功，4失败，99不支持转换，0不需要转换")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long transferStatus;
  @Schema(description = "判断文件是否加密，默认值0；1为已加密")
  @ExcelProperty(value = "判断文件是否加密，默认值0；1为已加密")
  @JsonSerialize(using = ToStringSerializer.class)
  private Integer isSecret;
  @Schema(description = "ocr识别状态：默认0，读取pdf内容后值设为1")
  @ExcelProperty(value = "ocr识别状态：默认0，读取pdf内容后值设为1")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long ocrStatus;
  @Schema(description = "离线数据导入，附件标识")
  @ExcelProperty(value = "离线数据导入，附件标识")
  private String did;
  @Schema(description = "文件类型:正文")
  @ExcelProperty(value = "文件类型:正文")
  private String docType;
  @Schema(description = "档案日期，从文档继承而来")
  @ExcelProperty(value = "档案日期，从文档继承而来")
  private String docDate;
  @Schema(description = "记录附件属性信息java使用")
  @ExcelProperty(value = "记录附件属性信息java使用")
  private String fileText;
  @Schema(description = "缩略图")
  @ExcelProperty(value = "缩略图")
  private String thumb;
  @Schema(description = "单位“幅”")
  @ExcelProperty(value = "单位“幅”")
  private String fu;
  @Schema(description = "音视频“时长”")
  @ExcelProperty(value = "音视频“时长”")
  private String duration;
  @Schema(description = "电子章状态：0（默认），1（需要添加电子章），其它状态java维护")
  @ExcelProperty(value = "电子章状态：0（默认），1（需要添加电子章），其它状态java维护")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long eSeal;
  @Schema(description = "md5字段信息")
  @ExcelProperty(value = "md5字段信息")
  private String md5Ecode;
  @Schema(description = "国密sm3字段")
  @ExcelProperty(value = "国密sm3字段")
  private String sm3;
  @Schema(description = "四性检查可用性")
  @ExcelProperty(value = "四性检查可用性")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long fileAvaiable;
  @Schema(description = "格式信息")
  @ExcelProperty(value = "格式信息")
  private String formatInfo;
  @Schema(description = "文档创建程序")
  @ExcelProperty(value = "文档创建程序")
  private String docCreateSoft;
  @Schema(description = "信息系统描述")
  @ExcelProperty(value = "信息系统描述")
  private String sysInfo;
  @Schema(description = "电子签名信息")
  @ExcelProperty(value = "电子签名信息")
  private String eleSignature;
  @Schema(description = "软件环境信息")
  @ExcelProperty(value = "软件环境信息")
  private String softInfo;
  @Schema(description = "硬件环境信息")
  @ExcelProperty(value = "硬件环境信息")
  private String hardwareInfo;
  @Schema(description = "媒体类扩展信息")
  @ExcelProperty(value = "媒体类扩展信息")
  private String mediaInfo;
  @Schema(description = "文件页数")
  @ExcelProperty(value = "文件页数")
  @JsonSerialize(using = ToStringSerializer.class)
  private Integer filePage;
  @Schema(description = "统计转换后附件大小")
  @ExcelProperty(value = "统计转换后附件大小")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long pdfSize;
  /** 显示的扩展名 */
  @Schema(description = "显示的扩展名")
  @ExcelProperty(value = "显示的扩展名")
  private String showExt;
  @Schema(description = "该字段用来表示附件迁移的状态，0表示未迁移，1表示迁移成功，2表示迁移失败")
  @ExcelProperty(value = "该字段用来表示附件迁移的状态，0表示未迁移，1表示迁移成功，2表示迁移失败")
  private Long moveStatus;
  @Schema(description = "该字段用来记录生成的辅助文件的路径（如生成的以_index.txt为结尾的索引文件）")
  @ExcelProperty(value = "该字段用来记录生成的辅助文件的路径（如生成的以_index.txt为结尾的索引文件）")
  private String showFilePath;
  @Schema(description = "记录电子章信息")
  @ExcelProperty(value = "记录电子章信息")
  private String sealInfo;
  @Schema(description = "文件整理标识")
  @ExcelProperty(value = "文件整理标识")
  @JsonSerialize(using = ToStringSerializer.class)
  private Integer arrangeStatus;
  @Schema(description = "原文存储位置")
  @ExcelProperty(value = "原文存储位置")
  private String oldSaveFilePath;
  @Schema(description = "索引状态：初始值0不需要建索引，1需要建索引,2已添加索引，3添加索引失败")
  @ExcelProperty(value = "索引状态：初始值0不需要建索引，1需要建索引,2已添加索引，3添加索引失败")
  @JsonSerialize(using = ToStringSerializer.class)
  private Long indexStatus;
  @Schema(description = "排序")
  @ExcelProperty(value = "排序")
  private Integer sort;
  @Schema(description = "创建人")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "创建人")
  private Long createBy;
  @Schema(description = "创建时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @ColumnWidth(20)
  @ExcelProperty(value = "创建时间")
  private Date createTime;
  @Schema(description = "更新人")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "更新人")
  private Long updateBy;
  @Schema(description = "更新时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @ColumnWidth(20)
  @ExcelProperty(value = "更新时间")
  private Date updateTime;
  /** 文件分类 */
  @Schema(description = "文件分类")
  @ExcelProperty(value = "文件分类")
  private Integer fileCategory;

  public String getFileSizeStr() {
    return DataSizeUtil.format(StrUtil.isNotBlank(fileSize) ? Long.parseLong(fileSize) : 0L);
  }
}
